<template>
  <div class="global-properties">
    <h1>globalProperties</h1>
    <div ref="LineChartRef" class="echart"></div>
  </div>
</template>
<script setup>
import { ref, onMounted, getCurrentInstance } from 'vue'
const LineChartRef = ref()
onMounted(() => {
  // 获取全局echarts实例
  const echarts = getCurrentInstance().appContext.config.globalProperties.$echarts
  // 基于准备好的dom，初始化echarts实例
  const lineChar = echarts.init(LineChartRef.value);
  // 绘制图表
  lineChar.setOption({
    title: {
      text: '折线图'
    },
    xAxis: {
      type: 'category',
      data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    },
    yAxis: {
      type: 'value'
    },
    series: [
      {
        data: [150, 230, 224, 218, 135, 147, 260],
        type: 'line'
      }
    ]
  });
})
</script>
<style lang="scss" scoped>
.global-properties {
  margin: auto;
  max-width: 60vw;

  .echart {
    width: 100%;
    height: 500px;
  }
}
</style>